WebGLContextDraw.cpp: the 'empty' method should be used to check for emptiness instead of 'size'
Categories
(Developer Infrastructure :: Source Code Analysis, task, P5)
Tracking
(firefox101 fixed)
Tracking | Status | |
---|---|---|
firefox101 | --- | fixed |
People
(Reporter: Sylvestre, Assigned: rzvncj, Mentored)
References
(Blocks 1 open bug)
Details
(Keywords: good-first-bug, Whiteboard: [lang=C++])
Attachments
(1 file, 1 obsolete file)
Filling as a good first bug to learn workflows.
intersection.size()
should use .empty() instead
As the change is trivial, it is just to learn how to contribute to Firefox.
Found by http://clang.llvm.org/extra/clang-tidy/checks/readability-container-size-empty.html
Tutorials to contribute:
https://firefox-source-docs.mozilla.org/tools/docs/contribute/how_to_contribute_firefox.html
https://firefox-source-docs.mozilla.org/contributing/stack_quickref.html
Please don't ask for the bug to be assigned. It will be automatically assigned to the first patch.
Updated•3 years ago
|
Assignee | ||
Comment 1•3 years ago
|
||
Use !intersection.empty() instead of bool(intersection.size()) to
check if the container is empty.
Updated•3 years ago
|
Assignee | ||
Comment 2•3 years ago
|
||
Not sure how these changes happened:
@@ -1061,7 +1061,8 @@ bool WebGLContext::DoFakeVertexAttrib0(c
////
const auto bytesPerVert = sizeof(mFakeVertexAttrib0Data);
- const auto checked_dataSize = CheckedInt<intptr_t>(totalVertCount) * bytesPerVert;
+ const auto checked_dataSize =
+ CheckedInt<intptr_t>(totalVertCount) * bytesPerVert;
if (!checked_dataSize.isValid()) {
ErrorOutOfMemory(
"Integer overflow trying to construct a fake vertex attrib 0"
@@ -1081,7 +1082,8 @@ bool WebGLContext::DoFakeVertexAttrib0(c
const auto err = errorScope.GetError();
if (err) {
- ErrorOutOfMemory("Failed to allocate fake vertex attrib 0 data: %zi bytes", dataSize);
+ ErrorOutOfMemory(
+ "Failed to allocate fake vertex attrib 0 data: %zi bytes", dataSize);
return false;
}
hg diff -c tip
(after the commit) shows them, but hg diff
(immediately after the change, but some time prior to the commit) did not. Maybe running ./mach lint
did it?
Anyway, I can try to figure this out and redo the patch if you'd like (so that the only thing changed is the relevant line). Let me know.
Assignee | ||
Comment 3•3 years ago
|
||
Use !intersection.empty() instead of bool(intersection.size()) to
check if the container is empty.
Assignee | ||
Comment 4•3 years ago
|
||
Figured the automatic indentation out, it was done by hg commit
, via clang-format. Updated my .hgrc
and now there are no more surprises. Sorry for the inconvenience - I'm really a git user.
Hope all's well with my latest submission. Thanks for the quick review!
Updated•3 years ago
|
Comment 6•3 years ago
|
||
bugherder |
Updated•3 years ago
|
Description
•